public class Cal {
    public int max (int x, int y)
    {
        return (x > y) ? x : y;
    }

    public int MaxSubSumOfSequence (int A[], int n)
    {
        int s[] = new int[n];
        int a[] = new int[n];
        s[n-1] = A[n-1];
        a[n-1] = A[n-1];
        for (int i = n-2; i >= 0; i--)
        {
            s[i] = max(A[i], A[i] + s[i+1]);
            a[i] = max(s[i], a[i+1]);
        }
        return a[0];
    }

}
